package cn.zwx.security.example.security.handler;

import cn.zwx.security.example.common.enums.ResultCodeEnum;
import cn.zwx.security.example.utils.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * @description 暂无权限处理类
 * @return
 * @author zhangwenxue
 * @createTime 2021/6/23 16:01
 **/
@Component
public class UserAuthAccessDeniedHandler implements AccessDeniedHandler {

    private static Logger logger = LoggerFactory.getLogger(UserAuthAccessDeniedHandler.class);


    /**
     * @description 暂无权限返回结果
     * @return void
     * @author zhangwenxue
     * @createTime 2021/6/23 16:02
     **/
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException exception){
        ResultUtil.responseJson(response,ResultCodeEnum.NO_PERMISSION);
    }


}